<template>
	<view class="content">
		<view class="row">
			<block v-for="(item,index) in tab_link" :key="index">
				<view class="t_center" :style="'width:'+ 100/tab_link.length + '%;'">
					<!-- <text class="active" @click="cindex=index">{{item.name}}</text> -->
					<view :class="cindex == index ? 'i_active':'i_title'">
						<text @click="click_index(index)">{{item.name}}</text>
					</view>
					<view class="i_img" v-show="cindex == index">
						<image src="../../static/index/user_bg.png" :style="'width:'+img_width+'%;'" mode="widthFix"></image>
					</view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'tab-select',
		props:{
			tab_link: {
				type: Array,
				default:()=>{
					return []
				}
			},
			cindex:{
				type: Number,
				default:()=>{
					return 0
				}
			},
			img_width: {
				type: Number,
				default:()=>{
					return 25
				}
			}
		},
		methods:{
			click_index(e){
				this.$emit('change',e)
			}
		}		
	}
</script>

<style lang="scss">
	.content{
		width: 94%;
		padding: 0 3%;
		height: 75rpx;
		line-height: 75rpx;
		background-color: #fff;
		color: #999999;
		font-size: 28rpx;
		.t_center{
			position: relative;
			.i_title,
			.i_active{
				position: relative;
				z-index: 6;
			}
			.i_active{
				color: #333333;
				font-size: 30rpx;
				font-weight: bold;
			}
			.i_img{
				position: absolute;
				z-index: 5;
				text-align: center;
				bottom: -10rpx;
				width: 100%;
			}
		}
	}
</style>
